<?php
/**
 * Created by Zhy
 * User: Zhy
 * Date: 2019/9/12
 * Time: 16:25
 */

namespace app\admin\controller;


use think\Db;
use think\Request;

class About extends Base
{
    /**
     * 学生端功能介绍
     * @return mixed|\think\response\Json
     */

    public function studentGn(){
        if(Request::instance()->isPost()){
            $content = input('about_student_gn');
            $res = Db::table('up_about')
                ->where('about_id', 1)
                ->update(['about_student_gn' => $content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $gn = Db::table('up_about')->where('about_id', 1)->value('about_student_gn');
        $this->assign('gn', $gn);
        return $this->fetch('about/studentgn');
    }
    
    /**
     * 学生端法律说明
     * @return mixed|\think\response\Json
     */
    public function studentLaw(){
        if(Request::instance()->isPost()){
            $content = input('about_student_law');
            $res = Db::table('up_about')
                ->where('about_id', 2)
                ->update(['about_student_law' => $content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $law = Db::table('up_about')->where('about_id', 2)->value('about_student_law');
        $this->assign('law', $law);
        return $this->fetch('about/studentlaw');
    }
    
    /**
     * 学生端平台协议
     * @return mixed|\think\response\Json
     */
    public function studentPlatform(){
        if(Request::instance()->isPost()){
            $content = input('about_student_platform');
            $res = Db::table('up_about')
                ->where('about_id', 3)
                ->update(['about_student_platform' => $content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $platform = Db::table('up_about')->where('about_id', 3)->value('about_student_platform');
        $this->assign('platform', $platform);
        return $this->fetch('about/studentplatform');
    }
    
    /**
     * 老师端功能介绍
     * @return mixed|\think\response\Json
     */
    public function teacherGn(){
        if(Request::instance()->isPost()){
            $content = input('about_teacher_gn');
            $res = Db::table('up_about')
                ->where('about_id', 4)
                ->update(['about_teacher_gn' => $content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $gn = Db::table('up_about')->where('about_id', 4)->value('about_teacher_gn');
        $this->assign('gn', $gn);
        return $this->fetch('about/teachergn');
    }
    
    /**
     * 老师端法律说明
     * @return mixed|\think\response\Json
     */
    public function teacherLaw(){
        if(Request::instance()->isPost()){
            $content = input('about_teacher_law');
            $res = Db::table('up_about')
                ->where('about_id', 5)
                ->update(['about_teacher_law' => $content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $law = Db::table('up_about')->where('about_id', 5)->value('about_teacher_law');
        $this->assign('law', $law);
        return $this->fetch('about/teacherlaw');
    }
    
    /**
     * 老师端平台协议
     * @return mixed|\think\response\Json
     */
    public function teacherPlatform(){
        if(Request::instance()->isPost()){
            $content = input('about_teacher_platform');
            $res = Db::table('up_about')
                ->where('about_id', 6)
                ->update(['about_teacher_platform' => $content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $platform = Db::table('up_about')->where('about_id', 6)->value('about_teacher_platform');
        $this->assign('platform', $platform);
        return $this->fetch('about/teacherplatform');
    }
    
    /**
     * 老师端隐私协议
     * @return mixed|\think\response\Json
     */
    public function teacherYinsi(){
        if(Request::instance()->isPost()){
            $content = input('about_teacher_yinsi');
            $res = Db::table('up_about')
                ->where('about_id', 10)
                ->update(['about_teacher_yinsi' => $content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $yinsi = Db::table('up_about')->where('about_id', 10)->value('about_teacher_yinsi');
        $this->assign('yinsi', $yinsi);
        return $this->fetch('about/teacheryinsi');
    }
    
    /**
     * 学生端隐私协议
     * @return mixed|\think\response\Json
     */
    public function studentYinsi(){
        if(Request::instance()->isPost()){
            $content = input('about_student_yinsi');
            $res = Db::table('up_about')
                ->where('about_id', 11)
                ->update(['about_student_yinsi' => $content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $yinsi = Db::table('up_about')->where('about_id', 11)->value('about_student_yinsi');
        $this->assign('yinsi', $yinsi);
        return $this->fetch('about/studentyinsi');
    }
    
    /**
     * 老师端服务协议
     * @return mixed|\think\response\Json
     */
    public function teacherServe(){
        if(Request::instance()->isPost()){
            $content = input('about_teacher_serve');
            $res = Db::table('up_about')
                ->where('about_id', 12)
                ->update(['about_teacher_serve' => $content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $serve = Db::table('up_about')->where('about_id', 12)->value('about_teacher_serve');
        $this->assign('serve', $serve);
        return $this->fetch('about/teacherserve');
    }
    
    /**
     * 学生端服务协议
     * @return mixed|\think\response\Json
     */
    public function studentServe(){
        if(Request::instance()->isPost()){
            $content = input('about_student_serve');
            $res = Db::table('up_about')
                ->where('about_id', 13)
                ->update(['about_student_serve' => $content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $serve = Db::table('up_about')->where('about_id', 13)->value('about_student_serve');
        $this->assign('serve', $serve);
        return $this->fetch('about/studentserve');
    }
    
    /**
     * 提现手续费
     * @return mixed|\think\response\Json
     */
    public function tiXian(){
        if(Request::instance()->isPost()){
            $dis = input('dis');
            $res = Db::table('up_about')
                ->where('about_id', 14)
                ->update(['about_tixian_dis' => $dis]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $dis = Db::table('up_about')->where('about_id', 14)->value('about_tixian_dis');
        $this->assign('dis', $dis);
        return $this->fetch('about/tixian');
    }
    
    /**
     * 返点比例
     * @return mixed|\think\response\Json
     */
    public function rebates(){
        if(Request::instance()->isPost()){
            $rebates = input('rebates');
            $res = Db::table('up_about')
                ->where('about_id', 15)
                ->update(['about_rebates' => $rebates]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $rebates = Db::table('up_about')->where('about_id', 15)->value('about_rebates');
        $this->assign('rebates', $rebates);
        return $this->fetch('about/rebates');
    }
    
    /**
     * 提现说明
     * @return mixed|\think\response\Json
     */
    public function tixianExplain(){
        if(Request::instance()->isPost()){
            $explain = input('explain');
            $res = Db::table('up_about')
                ->where('about_id', 16)
                ->update(['about_tixian_explain' => $explain]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $tixian_explain = Db::table('up_about')->where('about_id', 16)->value('about_tixian_explain');
        $this->assign('explain', $tixian_explain);
        return $this->fetch('about/tixianexplain');
    }
    
    /**
     * 最小提现金额
     * @return mixed|\think\response\Json
     */
    public function minTiXian(){
        if(Request::instance()->isPost()){
            $min_price = input('min_price');
            if($min_price < 2) return json(['code' => 100, 'msg' => '最小金额不得低于2元']);
            $res = Db::table('up_about')
                ->where('about_id', 17)
                ->update(['about_tixian_price' => $min_price]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $tixian_price = Db::table('up_about')->where('about_id', 17)->value('about_tixian_price');
        $this->assign('tixian_price', $tixian_price);
        return $this->fetch('about/mintixian');
    }
    
    /**
     * 提现后账户最小余额
     * @return mixed|\think\response\Json
     */
    public function minBalance(){
        if(Request::instance()->isPost()){
            $balance = (int)input('balance');
            if($balance < 100){
                return json(['code' => 100, 'msg' => '不得低于100元']);
            }
            $res = Db::table('up_about')
                ->where('about_id', 18)
                ->update(['about_balance' => $balance]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $min_balance = Db::table('up_about')->where('about_id', 18)->value('about_balance');
        $this->assign('min_balance', $min_balance);
        return $this->fetch('about/minbalance');
    }
}